<html lang="en">
<head>
    <title>注册游记管理</title>
<#include  "../common/header.ftl">
    <script>
        $(function () {
            //点击修改或者添加弹出模态框--------
            $(".editBtn").click(function () {
                //清空表单
                $("#editForm")[0].reset();

                var json = $(this).data("json");
                if (json) {
                    $("#editForm input[name='title']").val(json.title);
                    $("#editForm input[name='id']").val(json.id);
                    $("#editForm input[name='subTitle']").val(json.subTitle);
                    $("#editForm input[name='coverUrl']").val(json.coverUrl);
                    $("#editForm img[name='coverUrl']").attr("src", json.coverUrl);

                    $("#editForm select[name='place.id']").val(json.placeId);
                    console.log(json.placeId);
                    $("#editForm select[name='state']").val(json.state);
                }
                $("#strategyModal").modal("show");
            })
            //end--------------------------
            //当点击保存时提交表单
            $("#saveBtn").click(function () {
                $("#editForm").submit();
            })

        })
    </script>
    <style>
        #strategyModal img {
            width: 100%;
        }

        #strategyModal .modal-body {
            max-height: 600px;
            overflow-y: auto;
        }
    </style>
</head>
<body>
<!--左侧菜单回显变量设置-->
<#assign currentMenu='strategy'>


<div class="container " style="margin-top: 20px">
<#include  "../common/top.ftl">
    <div class="row">
        <div class="col-sm-2">
        <#include  "../common/menu.ftl">
        </div>
        <div class="col-sm-10">
            <div class="row">
                <div class="col-sm-12">
                    <h1 class="page-head-line">大攻略管理</h1>
                </div>
            </div>
            <!--高级查询--->
            <form class="form-inline" id="searchForm" action="/strategy/list.do" method="post">
                <input type="hidden" name="currentPage" id="currentPage" value="1">
                <div class="form-group">
                    <label for="keyword">关键字:</label>
                    <input type="text" class="form-control" id="keyword" name="keyword" value="${qo.keyword!}">
                </div>
                <button id="btn_query" class="btn btn-info"><span class="glyphicon glyphicon-search"></span> 查询</button>
                <a href="javascript:void(-1);" class="btn btn-success editBtn" id="addStrategyBtn">添加攻略</a>
            </form>

            <table class="table table-striped table-hover">
                <thead>
                <th>编号</th>
                <th>封面</th>
                <th>攻略标题</th>
                <th>副标题</th>
                <th>所属地区</th>
                <th>状态</th>
                <th>操作</th>
                </tr>
                </thead>

            <#list result.list as entity>
                <tr>
                    <td>${entity_index + 1}</td>
                    <td><img src="${entity.coverUrl!}" width="100px"></td>
                    <td>${(entity.title)!}</td>
                    <td>${(entity.subTitle)!}</td>
                    <td>${(entity.place.name)!}</td>
                    <td>${(entity.stateDisplay)!}</td>
                    <td>
                        <a href="javascript:;" data-json='${entity.jsonString}' class="editBtn">修改</a>&nbsp;&nbsp;
                    </td>
                </tr>
            </#list>

            </table>
        <#include "../common/page.ftl">
        </div>
    </div>
</div>


<#--查看内容模态框-->
<div id="strategyModal" class="modal" tabindex="-1" role="dialog">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span>
                </button>
                <h4 class="modal-title">编辑/增加</h4>
            </div>
            <div class="modal-body">
                <form id="editForm" class="form-horizontal" method="post" enctype="multipart/form-data"
                      action="/strategy/saveOrUpdate.do" strategyIdstyle="margin: -3px 118px">
                    <input type="hidden" name="id"/>
                    <div class="form-group">
                        <label class="col-sm-4 control-label">标题</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" id="title" name="title" placeholder="攻略标题">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-4 control-label">副标题</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" id="subTitle" name="subTitle" placeholder="副标题">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-4 control-label">封面</label>
                        <div class="col-sm-6">
                            <img id="coverUrl" name="coverUrl" width="200px"/>
                            <input type="file" class="form-control" id="coverUrl" name="file">
                            <input type="hidden" name="coverUrl">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-4 control-label">所属地区</label>
                        <div class="col-sm-6">
                            <select name="place.id" class="form-control">
                            <#list regions as r>
                                <option value="${r.id}">${r.name}</option>
                            </#list>
                            </select>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-4 control-label">状态</label>
                        <div class="col-sm-6">
                            <select id="state" class="form-control" autocomplete="off" name="state" placeholder="状态">
                                <option value="0">正常</option>
                                <option value="1">推荐</option>
                                <option value="2">禁用</option>
                            </select>
                        </div>

                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <a href="javascript:void(0);" class="btn btn-success" id="saveBtn" aria-hidden="true">保存</a>
                <a href="javascript:void(0);" class="btn" data-dismiss="modal" aria-hidden="true">关闭</a>
            </div>
        </div>
    </div>
</div>

</body>
</html>